import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/page/Login'
import Index from '~/page/Index'

Vue.use(Router);

export default new Router({
  // mode: 'history',
  routes: [
    {
      path:'/',
      component: Login
    },
    {
      path:'/index',
      component: Index,
      name:'首页'
    },
    {
      path:'/home',
      component:resolve => require(['@/page/home/Index'],resolve),
      name:'官页管理',
      redirect:'/home/article/list',
      children:[
        {
          path: 'article/list',
          component: resolve => require(['@/page/home/article/List'],resolve),
          name:'首推管理'
        },
        {
          path: 'poster/list',
          component: resolve => require(['@/page/home/poster/List'],resolve),
          name:'海报管理'
        },
        {
          path: 'ad/list',
          component: resolve => require(['@/page/home/ad/List'],resolve),
          name:'广告管理'
        }
      ]
    },
    {
      path:'/push',
      component:resolve => require(['@/page/push/Index'],resolve),
      name:'推送管理',
      redirect:'/push/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/push/List'],resolve)
        }
      ]
    },
    {
      path:'/message',
      component:resolve => require(['@/page/message/Index'],resolve),
      name:'消息管理',
      redirect:'/message/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/message/List'],resolve)
        }
      ]
    },
    {
      path:'/user',
      component:resolve => require(['@/page/user/Index'],resolve),
      name:'用户管理',
      redirect:'/user/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/user/List'],resolve)
        }
      ]
    },
    {
      path:'/activity',
      component:resolve => require(['@/page/activity/Index'],resolve),
      name:'活动管理',
      redirect:'/activity/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/activity/List'],resolve)
        }
      ]
    },
    {
      path:'/review',
      component:resolve => require(['@/page/review/Index'],resolve),
      name:'审核管理',
      redirect:'/review/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/review/List'],resolve)
        }
      ]
    },
    {
      path:'/comment',
      component:resolve => require(['@/page/comment/Index'],resolve),
      name:'评论管理',
      redirect:'/comment/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/comment/List'],resolve)
        }
      ]
    },
    {
      path:'/article',
      component:resolve => require(['@/page/article/Index'],resolve),
      name:'文章管理',
      redirect:'/article/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/article/List'],resolve)
        }
      ]
    },
    {
      path:'/book',
      component:resolve => require(['@/page/book/Index'],resolve),
      name:'书籍管理',
      redirect:'/book/list',
      children:[
        {
          path: 'list',
          component: resolve => require(['@/page/book/List'],resolve)
        }
      ]
    }
  ],
  scrollBehavior (to, from, savedPosition) {
    return {x:0,y:0}
    // return 期望滚动到哪个的位置
  }
})
